package com.study.gupao.proxy.gpproxy;

import com.study.gupao.proxy.Person;
import com.study.gupao.proxy.jdkproxy.Girl;
import com.study.gupao.proxy.jdkproxy.Matchmaker;
import com.study.gupao.service.IUserService;
import com.study.gupao.service.impl.UserServiceImpl;

/**
 * @ClassName: GPProxyTest
 * @Description:   测试自定义动态代理
 * @author: Adminstrator
 * @Date: 2019-03-10 21:50
 */
public class GPProxyTest {

    public static void main(String[] args) {
        IUserService userService = new UserServiceImpl();
        GPProxy.newProxyInstance(new GPClassLoader(),userService.getClass().getInterfaces(),
                (target,method,argss)->{
                    System.out.println("在方法执行之前");
                    Object result = method.invoke(userService, argss);
                    System.out.println("在方法执行之后");
                    return result;
                });

        userService.login("张三丰");
    }
    /*public static void main(String[] args) {
        try {
            Person obj = (Person) new ProxyMatchmaker().getInstance(new Girl());
            obj.findLove();
        }catch (Exception e){
            e.printStackTrace();
        }
    }*/
}
